#!/bin/bash

# 把一个文件的内容全部转换为大写. 
#IFS_old= $IFS
#IFS= $'\n'

BIG=65
if [ -z "$1" ];then  # 检查命令行参数,如果$1长度为0，则为真
	echo "Usage: `basename $0` filename"
    exit $BIG
fi 

#此句就是将小写转换为大写，牢记！
#tr a-z A-Z < "$1"

# 与上边的作用相同, 但是使用了POSIX字符集标记方法:
# tr '[:lower:]' '[:upper:]' <"$1"

name="$1"
echo $name

newname=${name}".bak"
#echo $newname

#for line in `cat $1`
#do
#	echo $line | tr 'a-z' 'A-Z' >> $newname  
#done

cat $name | while read line
do
	echo $line
	count=`echo $line | grep "row" | wc -l`
	if [ $count -eq 0 ] ; then
		echo "$line" | tr 'a-z' 'A-Z' >> $newname
	else
		echo "$line" >> $newname	
	fi

done

#将IFS变量还原为默认值
#IFS = $IFS_old

exit 0

